/*
 * FindReplacePanel
 * Copyright (C) 2011, Aleksey Nikiforov
 *
 * This file is part of FindReplacePanel.
 *
 * FindReplacePanel is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FindReplacePanel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package simplex3d.console.findreplace;


/**
 *
 * @author Aleksey Nikiforov (lex)
 */
public class SearchParams {
    
    final String find;
    final String replace;

    final boolean matchCase;
    final boolean wholeWords;
    final boolean regularExpression;
    final boolean highlight;

    
    public SearchParams(
        String find, String replace,
        boolean matchCase, boolean wholeWords, boolean regularExpression, boolean highlight
    ) {
        this.find = find;
        this.replace = replace;

        this.matchCase = matchCase;
        this.wholeWords = wholeWords;
        this.regularExpression = regularExpression;
        this.highlight = highlight;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final SearchParams other = (SearchParams) obj;
        if ((this.find == null) ? (other.find != null) : !this.find.equals(other.find)) {
            return false;
        }
        if ((this.replace == null) ? (other.replace != null) : !this.replace.equals(other.replace)) {
            return false;
        }
        if (this.matchCase != other.matchCase) {
            return false;
        }
        if (this.wholeWords != other.wholeWords) {
            return false;
        }
        if (this.regularExpression != other.regularExpression) {
            return false;
        }
        if (this.highlight != other.highlight) {
            return false;
        }
        return true;
    }

    public boolean euqalsAsMatcher(SearchParams other) {
        if (other == null) {
            return false;
        }
        if ((this.find == null) ? (other.find != null) : !this.find.equals(other.find)) {
            return false;
        }
        if (this.matchCase != other.matchCase) {
            return false;
        }
        if (this.wholeWords != other.wholeWords) {
            return false;
        }
        if (this.regularExpression != other.regularExpression) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.find != null ? this.find.hashCode() : 0);
        hash = 97 * hash + (this.replace != null ? this.replace.hashCode() : 0);
        hash = 97 * hash + (this.matchCase ? 1 : 0);
        hash = 97 * hash + (this.wholeWords ? 1 : 0);
        hash = 97 * hash + (this.regularExpression ? 1 : 0);
        hash = 97 * hash + (this.highlight ? 1 : 0);
        return hash;
    }
}
